﻿#region Usings
using System;
using BK.BL;
using BK.Entities;
using BK.WebSite.AppCode;
using Lib.Data.CriteriaRoutine;
#endregion

namespace BK.WebSite.Controls
{
	public partial class AccountEditControl : BkDataEditControl<AccountEntity, Accounts>
	{
		#region Instance Methods
		protected override void DoGetObjectFromEditor(AccountEntity entity)
		{
			entity.Name = tbxName.Text;
			entity.UserId.Value =
				BlContext.Instance.Users.LoadSingle(new Criteria("Login", Clause.Eq, Page.User.Identity.Name)).Id.Value;
			entity.CurrencyId.Assign(currencySelector.CurrencyId);
		}

		protected override void DoPutObjectToEditor(AccountEntity entity)
		{
			tbxName.Text = entity.Name;
			currencySelector.CurrencyId = entity.CurrencyId;
		}

		protected override void PrepareEditor()
		{
		}

		protected void Page_Load(object sender, EventArgs e)
		{
		}
		#endregion
	}
}